<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Keith&#39;s blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="Keith's blog">
<meta property="og:url" content="https://madordie.github.io/index.html">
<meta property="og:site_name" content="Keith's blog">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Keith's blog">
  
    <link rel="alternate" href="/atom.xml" title="Keith&#39;s blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Keith&#39;s blog</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">技术狂热粉</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://madordie.github.io"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-reactivecocoa-ready-to-use" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/07/12/reactivecocoa-ready-to-use/" class="article-date">
  <time datetime="2016-07-12T01:53:14.000Z" itemprop="datePublished">2016-07-12</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/07/12/reactivecocoa-ready-to-use/">准备食用RAC(ReactiveCocoa)的顾虑</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h1><p>众所周知，RAC很火，有很多崇拜者。本文只是一个新手第一次使用RAC时候所顾忌的一些问题，如果有比较好的解决方案及时告知我，我会及时更改。</p>
<h1 id="OC简单食用方法"><a href="#OC简单食用方法" class="headerlink" title="OC简单食用方法"></a>OC简单食用方法</h1><p>先来个例子代码：</p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">RACSignal *RSignal = [[<span class="keyword">self</span>.R rac_newValueChannelWithNilValue:@<span class="number">0</span>] startWith:@(<span class="keyword">self</span>.R.value)];</div><div class="line">RACSignal *GSignal = [[<span class="keyword">self</span>.G rac_newValueChannelWithNilValue:@<span class="number">0</span>] startWith:@(<span class="keyword">self</span>.G.value)];</div><div class="line">RACSignal *BSignal = [[<span class="keyword">self</span>.B rac_newValueChannelWithNilValue:@<span class="number">0</span>] startWith:@(<span class="keyword">self</span>.B.value)];</div><div class="line"></div><div class="line"><span class="built_in">NSString</span>*(^valueFormat)(<span class="built_in">NSNumber</span> *value) = ^(<span class="built_in">NSNumber</span> *value) &#123;</div><div class="line">    <span class="keyword">return</span> [<span class="built_in">NSString</span> stringWithFormat:<span class="string">@"%.0f"</span>, [value doubleValue]*<span class="number">255</span>];</div><div class="line">&#125;;</div><div class="line"></div><div class="line">[RSignal subscribeNext:^(<span class="keyword">id</span> x) &#123;</div><div class="line">    <span class="keyword">self</span>.RVaule.text = valueFormat(x);</div><div class="line">&#125;];</div><div class="line">[GSignal subscribeNext:^(<span class="keyword">id</span> x) &#123;</div><div class="line">    <span class="keyword">self</span>.GValue.text = valueFormat(x);</div><div class="line">&#125;];</div><div class="line">[BSignal subscribeNext:^(<span class="keyword">id</span> x) &#123;</div><div class="line">    <span class="keyword">self</span>.BValue.text = valueFormat(x);</div><div class="line">&#125;];</div></pre></td></tr></table></figure>
<p>是不是超级简单！</p>
<h2 id="顾虑"><a href="#顾虑" class="headerlink" title="顾虑"></a>顾虑</h2><p>可是我有一个问题：</p>
<ul>
<li>OC属于运行时语法，这个里面的<code>id x</code>的不确定因素可能会导致类型识别出现错误。如果说项目是多人维护，那么A可能不知道B写的Signal走的类型是什么，所以这个问题就不适用于松散的多人开发。</li>
</ul>
<h1 id="Swift简单食用方法"><a href="#Swift简单食用方法" class="headerlink" title="Swift简单食用方法"></a>Swift简单食用方法</h1>
      
    </div>
    <footer class="article-footer">
      <a data-url="https://madordie.github.io/2016/07/12/reactivecocoa-ready-to-use/" data-id="ciqoofxj90003kl6ark6mw1s9" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ReactiveCocoa/">ReactiveCocoa</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-use-hexo-setup-blog" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/07/05/use-hexo-setup-blog/" class="article-date">
  <time datetime="2016-07-05T10:03:31.000Z" itemprop="datePublished">2016-07-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/教程/">教程</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/07/05/use-hexo-setup-blog/">使用hexo搭建博客</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="参考博客"><a href="#参考博客" class="headerlink" title="参考博客"></a>参考博客</h1><p>感谢 <a href="http://lovenight.github.io" target="_blank" rel="external">岁月如歌</a> 的这个<a href="http://lovenight.github.io/2015/11/10/Hexo-3-1-1-静态博客搭建指南/" target="_blank" rel="external">《Hexo 3.1.1 静态博客搭建指南》</a>同时感谢这个<a href="http://lovenight.github.io/2015/11/18/向百度推送hexo博客所有链接的Python脚本/" target="_blank" rel="external">《向百度推送hexo博客所有链接的Python脚本》</a>(别问我为啥点不开，这个要问博主，不过要看这个文章也不是没办法的😂，因为这个博客也用git管理的。。。你懂)</p>
<h1 id="脚本修改"><a href="#脚本修改" class="headerlink" title="脚本修改"></a>脚本修改</h1><p>上面说的博主大约用的是windows，所以脚本并不能立马的运行在Mac上，需要做些修改：故修改为：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#!/usr/bin/env python</span></div><div class="line"><span class="comment"># -*- coding: utf-8 -*-</span></div><div class="line"><span class="comment"># @Author: LoveNight</span></div><div class="line"><span class="comment"># @Date:   2015-11-16 20:45:59</span></div><div class="line"><span class="comment"># @Last Modified by:   LoveNight</span></div><div class="line"><span class="comment"># @Last Modified time: 2015-11-18 18:07:19</span></div><div class="line"></div><div class="line"><span class="comment"># @Last Modified by:   Keith</span></div><div class="line"><span class="comment"># @Last Modified time: 2016-07-06 16:22:45</span></div><div class="line"><span class="keyword">import</span> os</div><div class="line"><span class="keyword">import</span> sys</div><div class="line"><span class="keyword">import</span> json</div><div class="line"><span class="keyword">from</span> bs4 <span class="keyword">import</span> BeautifulSoup <span class="keyword">as</span> BS</div><div class="line"><span class="keyword">import</span> requests</div><div class="line"><span class="comment">#import msvcrt</span></div><div class="line"></div><div class="line"><span class="string">"""</span></div><div class="line">hexo 博客专用，向百度站长平台提交所有网址</div><div class="line"></div><div class="line">本脚本必须放在hexo博客的根目录下执行！需要已安装生成百度站点地图的插件。</div><div class="line">百度站长平台提交链接：http://zhanzhang.baidu.com/linksubmit/index</div><div class="line">主动推送：最为快速的提交方式，推荐您将站点当天新产出链接立即通过此方式推送给百度，以保证新链接可以及时被百度收录。</div><div class="line">从中找到自己的接口调用地址</div><div class="line"></div><div class="line">python环境：</div><div class="line">pip install beautifulsoup4</div><div class="line">pip install requests</div><div class="line">xcode-select --install	</div><div class="line">pip install lxml </div><div class="line"></div><div class="line">"""</div><div class="line"></div><div class="line"><span class="comment"># ❌❌❌ 抄的需要更改这个URL！！这是我的！！❌❌❌</span></div><div class="line">url = <span class="string">'http://data.zz.baidu.com/urls?site=https://madordie.github.io&amp;token=j33t0VEPFl24tJ8N'</span></div><div class="line">baidu_sitemap = os.path.join(sys.path[<span class="number">0</span>], <span class="string">'public'</span>, <span class="string">'baidusitemap.xml'</span>)</div><div class="line">google_sitemap = os.path.join(sys.path[<span class="number">0</span>], <span class="string">'public'</span>, <span class="string">'sitemap.xml'</span>)</div><div class="line">sitemap = [baidu_sitemap, google_sitemap]</div><div class="line"></div><div class="line"><span class="keyword">assert</span> (os.path.exists(baidu_sitemap) <span class="keyword">or</span> os.path.exists(</div><div class="line">    google_sitemap)), <span class="string">"没找到任何网站地图，请检查！"</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment"># 从站点地图中读取网址列表</span></div><div class="line"><span class="function"><span class="keyword">def</span> <span class="title">getUrls</span><span class="params">()</span>:</span></div><div class="line">    urls = []</div><div class="line">    <span class="keyword">for</span> _ <span class="keyword">in</span> sitemap:</div><div class="line">        <span class="keyword">if</span> os.path.exists(_):</div><div class="line">            <span class="keyword">with</span> open(_, <span class="string">"r"</span>) <span class="keyword">as</span> f:</div><div class="line">                xml = f.read()</div><div class="line">        soup = BS(xml, <span class="string">"xml"</span>)</div><div class="line">        tags = soup.find_all(<span class="string">"loc"</span>)</div><div class="line">        urls += [x.string <span class="keyword">for</span> x <span class="keyword">in</span> tags]</div><div class="line">        <span class="keyword">if</span> _ == baidu_sitemap:</div><div class="line">            tags = soup.find_all(<span class="string">"breadCrumb"</span>, url=<span class="keyword">True</span>)</div><div class="line">            urls += [x[<span class="string">"url"</span>] <span class="keyword">for</span> x <span class="keyword">in</span> tags]</div><div class="line">    <span class="keyword">return</span> urls</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment"># POST提交网址列表</span></div><div class="line"><span class="function"><span class="keyword">def</span> <span class="title">postUrls</span><span class="params">(urls)</span>:</span></div><div class="line">    urls = set(urls)  <span class="comment"># 先去重</span></div><div class="line">    print(<span class="string">"一共提取出 %s 个网址"</span> % len(urls))</div><div class="line">    print(urls)</div><div class="line">    data = <span class="string">"\n"</span>.join(urls)</div><div class="line">    <span class="keyword">return</span> requests.post(url, data=data).text</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</div><div class="line"></div><div class="line">    urls = getUrls()</div><div class="line">    result = postUrls(urls)</div><div class="line">    print(<span class="string">"提交结果："</span>)</div><div class="line">    print(result)</div><div class="line"><span class="comment">#    msvcrt.getch()</span></div></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      <a data-url="https://madordie.github.io/2016/07/05/use-hexo-setup-blog/" data-id="ciqoofxji0006kl6a6gg3ux4x" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hexo/">hexo</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-about-change-blog" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/07/05/about-change-blog/" class="article-date">
  <time datetime="2016-07-05T05:43:36.000Z" itemprop="datePublished">2016-07-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/公告/">公告</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/07/05/about-change-blog/">博客迁移公告</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>你敢信！我又搬家了。。</p>
<p>之前在<a href="http://www.cnblogs.com/madordie/" target="_blank" rel="external">博客园</a>后来又去了<a href="http://madordie.leanote.com" target="_blank" rel="external">蚂蚁笔记</a>，最后吧，我就到了<a href="https://madordie.github.io">这里</a>。</p>
<p>说下大体感受：</p>
<p><a href="http://www.cnblogs.com" target="_blank" rel="external">博客园</a>挺好的，不过不喜欢其编码方式，真的不喜欢。博客园的主题什么的都是可以定制，但是总归是写起来比较费劲的。</p>
<p><a href="https://leanote.com" target="_blank" rel="external">蚂蚁笔记</a>不错，我开始时候logo还不是这个<img src="http://7xvzwi.com1.z0.glb.clouddn.com/leanote_new_logo.png" width="15" alt="新logo">，原来logo是<img src="http://7xvzwi.com1.z0.glb.clouddn.com/leanote_old_logo.png" width="15" alt="旧logo">😂,不过现在已经很厉害了，开始了各种业务。期待会走得更好更远。</p>
<p>我是看了<a href="http://blog.devtang.com" target="_blank" rel="external">巧哥</a>的<a href="http://blog.devtang.com/2012/02/10/setup-blog-based-on-github/" target="_blank" rel="external">这个博文</a>才开始准备转到Github的。。赶脚markdown很好玩，虽然出来很早了，但是并没有仔细的去学习这个语法，于是乎这个博客就用<a href="https://hexo.io" target="_blank" rel="external">hexo</a>进行搭建，采用了<a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" rel="external">Yelee主题</a>。感觉很赞，主题的<a href="http://moxfive.coding.me/yelee/" target="_blank" rel="external">文档</a>也很给力。</p>
<p>虽然我还不知道怎么让百度收录我的Github，但是主要的是能尝试着自己想试试确没有尝试的事情！</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://madordie.github.io/2016/07/05/about-change-blog/" data-id="ciqoofxj30001kl6ay7l90uc5" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/公告/">公告</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/教程/">教程</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/ReactiveCocoa/">ReactiveCocoa</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/ReactiveCocoa/" style="font-size: 10px;">ReactiveCocoa</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/07/12/reactivecocoa-ready-to-use/">准备食用RAC(ReactiveCocoa)的顾虑</a>
          </li>
        
          <li>
            <a href="/2016/07/05/use-hexo-setup-blog/">使用hexo搭建博客</a>
          </li>
        
          <li>
            <a href="/2016/07/05/about-change-blog/">博客迁移公告</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 Keith<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>